package com.example.springboot09.shejimoshi;

/**
 * @ClassName 抽象工厂模式
 * @Description TODO
 * @Author tianqinglong
 * @Date 14:38 2022/7/25
 * @Version 1.0
 **/
public class 抽象工厂模式 {
    public static void main(String[] args) {
        System.out.println("=======小米系列产品=========");
        XiaomiFactory xiaomiFactory = new XiaomiFactory();

        IPhoneProduct iPhoneProduct = xiaomiFactory.iphoneProduct();
        iPhoneProduct.callup();
        iPhoneProduct.sendMS();

        IRouteProduct iRouteProduct = xiaomiFactory.routeProduct();
        iRouteProduct.openWife();

        System.out.println("=======华为系列产品=========");
        HuaweiFactory huaweiFactory = new HuaweiFactory();

        iPhoneProduct = huaweiFactory.iphoneProduct();
        iPhoneProduct.callup();
        iPhoneProduct.sendMS();

        iRouteProduct = huaweiFactory.routeProduct();
        iRouteProduct.openWife();
    }
}
interface IPhoneProduct {
    void start();
    void shutdown();
    void callup();
    void sendMS();
}
interface IRouteProduct {
    void start();
    void shutdown();
    void openWife();
    void setting();
}
class XiaomiPhone implements IPhoneProduct {
    @Override
    public void start() {
        System.out.println("开启小米手机");
    }

    @Override
    public void shutdown() {
        System.out.println("关闭小米手机");
    }

    @Override
    public void callup() {
        System.out.println("小米打电话");
    }

    @Override
    public void sendMS() {
        System.out.println("小米发短信");
    }
}
class XiaomiRouter implements IRouteProduct{
    @Override
    public void start() {
        System.out.println("启动小米路由器");
    }

    @Override
    public void shutdown() {
        System.out.println("关闭小米路由器");
    }

    @Override
    public void openWife() {
        System.out.println("开启小米wifi");

    }

    @Override
    public void setting() {
        System.out.println("设置小米路由器");
    }
}
class HuaweiPhone implements IPhoneProduct {
    @Override
    public void start() {
        System.out.println("开启华为手机");
    }

    @Override
    public void shutdown() {
        System.out.println("关闭华为手机");
    }

    @Override
    public void callup() {
        System.out.println("华为打电话");
    }

    @Override
    public void sendMS() {
        System.out.println("华为发短信");
    }
}
class HuaweiRouter implements IRouteProduct{
    @Override
    public void start() {
        System.out.println("启动华为路由器");
    }

    @Override
    public void shutdown() {
        System.out.println("关闭华为路由器");
    }

    @Override
    public void openWife() {
        System.out.println("开启华为wifi");

    }

    @Override
    public void setting() {
        System.out.println("设置华为路由器");
    }
}
interface IProductFactory {
    //生产手机
    IPhoneProduct iphoneProduct();
    //生产路由器
    IRouteProduct routeProduct();
}
class XiaomiFactory implements IProductFactory{
    @Override
    public IPhoneProduct iphoneProduct() {
        return new XiaomiPhone();
    }

    @Override
    public IRouteProduct routeProduct() {
        return new XiaomiRouter();
    }
}
class HuaweiFactory implements IProductFactory{
    @Override
    public IPhoneProduct iphoneProduct() {
        return new HuaweiPhone();
    }

    @Override
    public IRouteProduct routeProduct() {
        return new HuaweiRouter();
    }
}
